/*
 * // Bristleback plugin - Copyright (c) 2010 bristleback.googlecode.com
 * // ---------------------------------------------------------------------------
 * // This program is free software; you can redistribute it and/or modify it
 * // under the terms of the GNU Lesser General Public License as published by the
 * // Free Software Foundation; either version 3 of the License, or (at your
 * // option) any later version.
 * // This library is distributed in the hope that it will be useful,
 * // but without any warranty; without even the implied warranty of merchantability
 * // or fitness for a particular purpose.
 * // You should have received a copy of the GNU Lesser General Public License along
 * // with this program; if not, see <http://www.gnu.org/licenses/lgpl.html>.
 * // ---------------------------------------------------------------------------
 */

package pl.bristleback.server.bristle.exceptions;

import org.apache.log4j.Logger;
import pl.bristleback.server.bristle.binding.BindingError;
import pl.bristleback.server.bristle.binding.BindingResult;

import java.util.List;

/**
 * This exception can be thrown during binding operations. Contains binding result wrapper.
 * <p/>
 * Created on: 2011-03-12 16:32:33 <br/>
 *
 * @author Wojciech Niemiec
 */
public class BindingException extends RuntimeException {
  private static Logger log = Logger.getLogger(BindingException.class.getName());

  private BindingResult<?> bindingResult;

  public BindingException(String message, BindingResult bindingResult) {
    super(message);
    this.bindingResult = bindingResult;
  }

  /**
   * Gets binding result wrapper.
   *
   * @return binding result.
   */
  public BindingResult<?> getBindingResult() {
    return bindingResult;
  }

  /**
   * Gets list of binding errors, most of all validation errors.
   *
   * @return binding errors.
   */
  public List<BindingError> getErrors() {
    return bindingResult.getErrors();
  }
}
